Объект App FeaturePython, или формально
Приложение::FeaturePython
, является простым экземпляром App DocumentObject в Python.
Это простой объект, который по умолчанию не имеет многих свойств, например таких как разположение и топологическая форма. Этот объект предназначен для общего использования; в зависимости от назначенных ему свойств его можно использовать для управления различными типами данных.
Упрощенная схема взаимосвязей между основными объектами в программе. Класс App::FeaturePython
является простой реализацией App::DocumentObject
, который можно использовать для любых целей, так как по умолчанию в нем нет TopoShape.
App FeaturePython является внутренним объектом, поэтому его нельзя создать с помощью графического интерфейса. Он предназначен для подклассов классов, которые будут обрабатывать различные типы данных.
For example, the Draft Text, Draft Dimension, and Draft WorkingPlaneProxy objects of the Draft Workbench are App::FeaturePython
objects with a custom icon and additional properties. They hold data but not an actual Part TopoShape.
If the desired object should have a placement, a shape, an attachment or other complex properties, it is better to create one of the more complex classes, for example, App GeoFeature, Part Feature, or Part Part2DObject.
See Property for all property types that scripted objects can have.
App FeaturePython (App::FeaturePython
класс) является производным от базового App DocumentObject (App::DocumentObject
класса), поэтому он разделяет все свойства последнего.
These are the properties available in the property editor. Hidden properties can be shown by using the Show all command in the context menu of the property editor.
Основные
PythonObject
): a custom class associated with this object.String
): the user editable name of this object, it is an arbitrary UTF8 string.String
): a longer, user editable description of this object, it is an arbitrary UTF8 string that may include newlines. By default, it is an empty string ""
.ExpressionEngine
): a list of expressions. By default, it is empty []
.Bool
): whether to display the object or not.Основные
PythonObject
): a custom viewprovider class associated with this object.Display Options
Enumeration
): it is empty by default.Bool
): it defaults to true
, in which case the object will appear in the Tree view; otherwise, the object will be hidden in the tree view. Once an object in the tree is invisible, you can see it again by opening the context menu over the name of the document (right-click), and selecting true
.Bool
): it defaults to true
, in which case the object will be visible in the 3D view if it has a Shape, otherwise it will be invisible. By default this property can be toggled on and off by selecting the object, and pressing the Space bar.Selection
Enumeration
): it controls the way in which the selection occurs in the 3D view if the object has a Shape, and there are many objects partially covered by others. It defaults to Disabled
, meaning that no special highlighting will occur; Enabled
means that the object will appear on top of any other object when selected; Object
means that the object will appear on top only if the entire object is selected in the Tree view; Element
means that the object will appear on top only if a subelement (vertex, edge, face) is selected in the 3D view.Enumeration
): it controls the way the object is highlighted if it has a Shape. If it is Shape
, the entire shape (vertices, edges, and faces) will be highlighted in the 3D view; if it is BoundBox
a bounding box will appear surrounding the object and will be highlighted.Смотрите так же: Основы составления скриптов в FreeCAD, и скриптовые объекты.
Общие сведения о добавлении объектов в программу смотрите в разделе Объект "Part::Feature".
App FeaturePython создается с помощью метода AddObject()
документа.
import FreeCAD as App
doc = App.newDocument()
obj = App.ActiveDocument.addObject("App::FeaturePython", "Name")
obj.Label = "Custom label"